package com.kun.hanlp.listener;

import com.hankcs.hanlp.dictionary.CustomDictionary;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;

import java.io.File;

/**
 * hanlp
 * 文件/文件夹的监听器
 */
@Slf4j
public class HanlpFileListener extends FileAlterationListenerAdaptor {

    /**
     * 文件改变
     **/
    @Override
    public void onFileChange(File file) {
        log.info("文件修改:{}", file.getAbsoluteFile());
        log.info("热部署自定义hanlp文件");
        CustomDictionary.reload();
    }

}
